// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use rusqlite::{Connection, Result};
fn initialize_database() -> Result<()> {
    // 打开或创建数据库文件
    let conn = Connection::open("todos.db")?;

    // 创建 todos 表
    conn.execute(
        "CREATE TABLE IF NOT EXISTS todos (
               id INTEGER PRIMARY KEY AUTOINCREMENT,
               text TEXT NOT NULL,
               completed BOOLEAN DEFAULT 0,
               created_at DATETIME DEFAULT CURRENT_TIMESTAMP
           )",
        [],
    )?;

    println!("Todos table created successfully.");
    Ok(())
}
fn main() {
    // 初始化数据库
    initialize_database().expect("Failed to initialize database");

    rmemtodo_lib::run()
}
